﻿<Window x:Class="CodeAngel.UI.PropertyDefWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:system="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:CodeAngel.UI"
        Title="PropertyDefWindow" SizeToContent="Height" Width="450" WindowStartupLocation="CenterOwner">

    <Window.Resources>

        <system:Double x:Key="LABEL_WIDTH">84.0</system:Double>

    </Window.Resources>

    <Grid Margin="6">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <StackPanel >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <local:LabeledTextBox Label="Name" Text="{Binding PropertyDef.Name}" LabelWidth="{StaticResource LABEL_WIDTH}" />
                <local:LabeledCheckBox Label="Is Keyword" IsChecked="{Binding PropertyDef.IsNameKeyword}" Grid.Column="1" Margin="6,0,0,0"/>
            </Grid>


            <local:LabeledTextBox Label="Purpose" Text="{Binding PropertyDef.Purpose}" LabelWidth="{StaticResource LABEL_WIDTH}" Height="60" />

            <local:LabeledComboBox Label="Data Type" ItemsSource="{Binding DataTypes}" LabelWidth="{StaticResource LABEL_WIDTH}"
                                   SelectedItem="{Binding PropertyDef.DataType, Mode=TwoWay}"/>
            

            <local:LabeledComboBox Label="Foreign Key" ItemsSource="{Binding ForeignKeyPropertyDefs}" LabelWidth="{StaticResource LABEL_WIDTH}"
                                   SelectedItem="{Binding PropertyDef.ForeignKeyPropertyDef, Mode=TwoWay}"/>
            <local:LabeledCheckBox Label="Can be Null" IsChecked="{Binding PropertyDef.IsNullable}" LabelWidth="{StaticResource LABEL_WIDTH}"/>
            <local:LabeledTextBox Label="Default Value" Text="{Binding PropertyDef.DefaultValue}" LabelWidth="{StaticResource LABEL_WIDTH}" />

            <GroupBox Header="Additional">
                <StackPanel Margin="4">
                    <local:LabeledTextBox Label="Friendly Name" Text="{Binding PropertyDef.FriendlyName}" LabelWidth="{StaticResource LABEL_WIDTH}" />
                    <local:LabeledTextBox Label="Column Name" Text="{Binding PropertyDef.DatabaseColumnName}" LabelWidth="{StaticResource LABEL_WIDTH}" />
                    
                    <GroupBox Header="SQL">
                        <StackPanel Margin="4">

                            <local:LabeledComboBox Label="Data Type" ItemsSource="{Binding SqlDataTypes}" LabelWidth="{StaticResource LABEL_WIDTH}"
                                   SelectedItem="{Binding PropertyDef.SqlDataType, Mode=TwoWay}"/>

                            <local:LabeledTextBox Label="Default" Text="{Binding PropertyDef.SqlDefaultValue}" LabelWidth="{StaticResource LABEL_WIDTH}"/>
                        </StackPanel>
                    </GroupBox>
                </StackPanel>
            </GroupBox>

        </StackPanel>


        <!-- Save and Cancel Buttons -->
        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="0,6,0,0">
            <Button Content="OK" Click="OkHandler" />
            <Button Content="Cancel" IsCancel="True" Margin="6,0,0,0" />
        </StackPanel>

    </Grid>
    
</Window>
